/*** tabdata5.do

This do-file merges prefecture level tabular data to create one data set.

***/

clear
set mem 100m
set more off
capture log close
log using tabdata5.log, replace text


************************ 1. Prepare various tabular sources for merging *********************************

use ..\..\data\tabular_data_BJ\source\ind_yb_rz.dta
***Fix these unit_status which are wrong
replace unit_status=5 if unit_code_08==130200 & year==1995
replace unit_status=5 if unit_code_08==130200 & year==2000
replace unit_status=5 if unit_code_08==130200 & year==2005
replace unit_status=4 if unit_code_08==130201 & year==1995
replace unit_status=4 if unit_code_08==130201 & year==2000
replace unit_status=4 if unit_code_08==130201 & year==2005
replace unit_status=5 if unit_code_08==130400 & year==1995
replace unit_status=4 if unit_code_08==130401 & year==1995
replace unit_status=5 if unit_code_08==510300 & year==2000
replace unit_status=4 if unit_code_08==510301 & year==2000
keep if unit_status==5
rename unit_code_08 city_code
sort city_code year
save temp_indyb.dta, replace

use ..\..\data\tabular_data_BJ\source\PY_2YCP_final_rz.dta
sort unit_code year 
merge unit_code year using ..\..\data\tabular_data_BJ\source\PY_ADCP_final_rz.dta, update
tab _merge
drop _merge
keep if year==1990|year==1995
gen city_code = unit_code
replace city_code = unit_code-100 if city_code-10*int(city_code/10)==0
replace city_code = unit_code-1 if city_code-10*int(city_code/10)==1
keep city_code year total_pop gdp
rename total_pop total_pop_cp
rename gdp gdp_py_cp
sort city_code year
save temp_2ycp.dta, replace
use ..\..\data\tabular_data_BJ\source\PY_ADPF_final_rz.dta
sort unit_code year
save ..\..\data\tabular_data_BJ\source\PY_ADPF_final_rz.dta, replace
use ..\..\data\tabular_data_BJ\source\PY_2YPF_final_rz.dta
sort unit_code year 
merge unit_code year using ..\..\data\tabular_data_BJ\source\PY_ADPF_final_rz.dta, update
tab _merge
drop _merge
keep if year==1990|year==1995
rename unit_code city_code
rename gdp gdp_py
*** Drop obs that clearly have cp level data instead
sort city_code year
merge city_code year using temp_2ycp.dta
tab _merge
drop _merge
drop if total_pop==total_pop_cp
drop if total_pop==-9 & gdp_py==-9
drop total_pop_cp gdp_py_cp
sort city_code year
save temp_2ypf.dta, replace
erase temp_2ycp.dta

use ..\..\data\tabular_data_BJ\source\MI_4YPF.dta
rename gdp gdp_michigan
rename gdp_sector2 gdp_sector2_mi
rename gdp_sector3 gdp_sector3_mi
rename total_pop pop
sort city_code year
save temp_mi3ypf.dta, replace

use ..\..\data\tabular_data_BJ\source\MI_ADPF.dta
sort city_code year
save ..\..\data\tabular_data_BJ\source\MI_ADPF.dta, replace


** Professor Zhang's dijishi.csv (HY 08/09/12)

insheet using ..\..\data\tabular_data_BJ\source\asset_dijishi.csv, clear
*** Drop Obs in which CP numbers are filled in for prefs
drop if net_asset_pref<=net_asset_cp & year==1990 & (city05~=420700 & city05==620200 & city05~=441900 & city05~=442000)
drop gross_asset_cp net_asset_cp
rename city_name city_namex
rename city05 city_code
rename gross_asset_pref asset_g_qz
rename net_asset_pref asset_n_qz
save temp_qz4.dta, replace
insheet using ..\..\data\tabular_data_BJ\source\assets_05.csv, clear
*** These are all CP numbers
drop net_asset_cp
rename city_name city_namex
rename city05 city_code
rename net_asset_pref asset_n_qz
append using temp_qz4
sort city_code year
save temp_qz4.dta, replace


******* 2. Save data for counties that switched prefectures ***********

use ..\..\data\tabular_data_BJ\generated\us123-census.dta
egen md05 = mode(city05), by(city_code year) minmode
keep if city05~=md05
keep city_code city05 year a434-expval a101-a874 gdp_predf gdp_predc gdp_sect2_predf gdp_sect2_predc culland
***This is the addition data set
save temp_us123.dta, replace

***Make a subtraction data set
foreach X of varlist a434-expval a101-a874 culland {
   replace `X' = -`X'
}
drop city05
save temp2_us123.dta, replace


/****** 3. Merge Data Sets to Correspondence Table Using 
					Prefecture/Year Units Only ********/

*** Create a data set of prefecture/year
use ..\..\data\tabular_data_BJ\generated\us123-census.dta
keep province_name province_code city_code city_name year city05
egen md05 = mode(city05), by(city_code year) minmode
keep if city05==md05
sort city_code year
by city_code year: keep if _n==1
sort city_code year

*** Individual Yearbook
merge city_code year using temp_indyb.dta
tab year _merge
rename _merge mrg_ind

*** Michigan
sort city_code year
merge city_code year using temp_mi3ypf.dta
tab year _merge

** These are the prefectures we dropped
drop if _merge==2
rename _merge mrg_MI3Y

*** Printed Yearbooks
sort city_code year
merge city_code year using temp_2ypf.dta
tab year _merge
** These are the prefectures we dropped
drop if _merge==2
rename _merge mrg_PY2Y

*** Annual Michigan Data
sort city_code year
merge city_code year using ..\..\data\tabular_data_BJ\source\MI_ADPF.dta
tab year _merge
** These are off-years & dropped prefectures
drop if _merge==2
rename _merge mrg_MIAD

*** Census Data
sort city_code year
merge city_code year using ..\..\data\census\generated\pf90.dta, update replace
tab _merge if year==1990
*These are prefectures outside of our study area
drop if _merge==2
rename _merge mrg_cen
drop mrg_*
rename avg_salary_of_staff_worker sal_staffwork
rename no_of_college_students college_stu
rename area_paved_roads area_pvdrd
rename paved_roads_percap pvdrd_percap
rename count_buses_trolleys bus_trol
rename so2_tons_year_km s02_tonyrkm
rename tot_fixed_invest tot_fixinv

** Professor Zhang's dijishi.csv (HY 08/09/12)

sort city_code year
merge city_code year using temp_qz4.dta
tab year _merge
drop if _merge==2
rename _merge mrg_QZ4

mvdecode totemp-fdi, mv(-9)
drop province unit nmcenmq

/** Deal with prefecture boundary changes: subtract units that moved 
from city_code to city05 and then add them to city05 **/
append using temp2_us123.dta
/*** Set all obs of variables to . if do not populate 
			all obs within groups. *****/
sort city_code year city05
by city_code year: replace city05 = city05[1] if city05==.
by city_code year: gen obs = _N

foreach X of varlist gdp-a874 asset_g_qz asset_n_qz {
   egen varcount = count(`X'), by(city_code city05 year)
   replace `X' = . if varcount<obs
   drop varcount
}

collapse (sum) gdp-a874 asset_g_qz asset_n_qz, by(city_code city05 year)

*** Set all 0s to .
mvdecode gdp-a874 asset_g_qz asset_n_qz, mv(0)
gen new = 0
append using temp_us123.dta
replace new = 1 if new==.
/*** Set all obs of variables to . if do not populate 
			all obs within groups. *****/
sort city05 year
by city05 year: gen obs = _N
foreach X of varlist gdp-a874 asset_g_qz asset_n_qz {
   egen varcount = count(`X'), by(city05 year)
   replace `X' = . if varcount<obs
   drop varcount
}
*** These are fully imputed prefectures
egen minnew = min(new), by(city05 year)
replace gdp_py = . if minnew==1
replace gdp_sect2 = . if minnew==1

collapse (sum) gdp-a874 asset_g_qz asset_n_qz obs, by(city05 year)

/*** All . aggregate to 0 so recode to . NOTE there are only a few genuine 0 obs
in the data, but none for population or gdp ***/
mvdecode gdp-a874 asset_g_qz asset_n_qz, mv(0)
drop if city05==.

*** Indicator for a prefecture boundary change
gen chg = (obs>1)
drop obs

*** Label Variables
label variable gdp "(ind yrb)"
label variable nnp "(ind yrb)"
label variable gdp_sector1 "(ind yrb)"
label variable nnp_sector1 "(ind yrb)"
label variable gdp_sector2 "(ind yrb)"
label variable nnp_sector2 "(ind yrb)"
label variable gdp_sector3 "(ind yrb)"
label variable nnp_sector3 "(ind yrb)"
label variable tot_pop "(ind yrb)"
label variable r08_gdp "(ind yrb)"
label variable r08_nnp "(ind yrb)"
label variable r08_gdp_sector2 "(ind yrb)"
label variable r08_nnp_sector2 "(ind yrb)"
label variable r08_gdp_sector3 "(ind yrb)"
label variable r08_nnp_sector3 "(ind yrb)"
label variable r08_tot_pop "(ind yrb)"
label variable num_car "(ind yrb)"
label variable dust_ems "(ind yrb)"
label variable gas_ems "(ind yrb)"
label variable so2 "(ind yrb)"
label variable kproad "(ind yrb)"
label variable aproad "(ind yrb)"
label variable bustrly "(ind yrb)"
label variable numhins "(ind yrb)"
label variable arrived_fdi "(ind yrb)"
label variable tot_emp "(ind yrb)"
label variable tot_emp_sect2 "(ind yrb)"
label variable tot_emp_sect3 "(ind yrb)"
label variable giov "(ind yrb)"
label variable giov_soecol "(ind yrb)"
label variable tot_area "(ind yrb)"
label variable giov_new "(ind yrb)"
label variable giov_soecol_new "(ind yrb)"
label variable totemp "(py)"
label variable agremp "(py)"
label variable minemp "(py)"
label variable manuemp "(py)"
label variable egwemp "(py)"
label variable constemp "(py)"
label variable geolemp "(py)"
label variable tstemp "(py)"
label variable whoreemp "(py)"
label variable fininsemp "(py)"
label variable reemp "(py)"
label variable ssemp "(py)"
label variable hsemp "(py)"
label variable ecmemp "(py)"
label variable stemp "(py)"
label variable pubemp "(py)"
label variable gdp_py "(py adjusted with predicted when necessary)"
label variable gdp_sect2 "(py adjusted with predicted when necessary)"
label variable gdp_sect3 "(py)"
label variable total_pop "(py)"
label variable kmpr "(py)"
label variable apr "(py)"
label variable prpc "(py)"
label variable num_bt "(py)"
label variable so2 "(py)"
label variable avgsalary "(py)"
label variable num_colstd "(py)"
label variable givo "(py)"
label variable givo_soe "(py)"
label variable givo_colt "(py)"
label variable exp_lgt "(py)"
label variable num_hedu "(py)"
label variable publibcol "(py)"
label variable culland "(py+fenxian)"
label variable area "(py)"
label variable emp_sect2 "(py)"
label variable emp_sect3 "(py)"
label variable fixinvest "(py)"
label variable fdi "(py)"
label variable chg "1 if prefecture changed boundaries"
label variable a101 "Total no. of H                                            Table 2-19"
label variable a102 "Total P                                                            "
label variable a103 "Total M                                   H=household(s)           "
label variable a104 "Total F                                   M=male(s)                "
label variable a105 "Residents of urban wards: No. of H        F=female(s)              "
label variable a106 "                     : P               P=population (M+F)       "
label variable a107 "                     : M                                        "
label variable a108 "                     : F                                        "
label variable a109 "Residents of villages: No. of H                                    "
label variable a110 "                  : P                                           "
label variable a111 "                  : M                                           "
label variable a112 "                  : F                                           "
label variable a113 "Residents of rural units outside village jurisdiction: No. of H    "
label variable a114 "                                                  : P           "
label variable a115 "                                                  : M           "
label variable a116 "                                                  : F           "
label variable a117 "Non-agricultural H: P                                              "
label variable a118 "               : M                                              "
label variable a119 "               : F                                              "
label variable a120 "Agricultural H: P                                                  "
label variable a121 "           : M                                                  "
label variable a122 "           : F                                                  "
label variable a123 "Specially designated H and persons outside any H: P                "
label variable a124 "                                             : M                "
label variable a125 "                                             : F                "
label variable a126 "All residents of all zhen (townships) combined: No. of H  Table 2-11"
label variable a127 "                                       : P                  "
label variable a128 "                                       : M                  "
label variable a129 "                                       : F                  "
label variable a130 "Town residents in all zhen combined: No. of H                      "
label variable a131 "                                 : P                             "
label variable a132 "                                 : M                             "
label variable a133 "                                 : F                             "
label variable a134 "Rural residents in all zhen combined: No. of H                     "
label variable a135 "                                  : P                            "
label variable a136 "                                  : M                            "
label variable a137 "                                  : F                            "
label variable a138 "Non-agricultural H in all zhen combined: P                Table 2-12"
label variable a139 "                                     : M                         "
label variable a140 "                                     : F                         "
label variable a141 "Agricultural H in all zhen combined: P                             "
label variable a142 "                              : M                             "
label variable a143 "                           : F                                "
label variable a144 "Specially designated H, etc. in all zhen combined: P               "
label variable a145 "                                            : M               "
label variable a146 "                                            : F               "
label variable a181 "Total P, all ages and both sexes                                    A1"
label variable a182 "Total M, all ages                                                   A2"
label variable a183 "Total F, all ages                                                   A3"
label variable a184 "P 0-4                                                               A4"
label variable a185 "M 0-4                                                               A5"
label variable a186 "F 0-4                                                               A6"
label variable a187 "P 5-9                                                               A7"
label variable a188 "M 5-9                                                               A8"
label variable a189 "F 5-9                                                               A9"
label variable a190 "P 10-14                                                            A10"
label variable a191 "M 10-14                                                            A11"
label variable a192 "F 10-14                                                            A12"
label variable a193 "P 15-19                                                            A13"
label variable a194 "M 15-19                                                            A14"
label variable a195 "F 15-19                                                            A15"
label variable a196 "P 20-24                                                            A16"
label variable a197 "M 20-24                                                            A17"
label variable a198 "F 20-24                                                            A18"
label variable a199 "P 25-29                                                            A19"
label variable a200 "M 25-29                                                            A20"
label variable a201 "F 25-29                                                            A21"
label variable a202 "P 30-34                                                            A22"
label variable a203 "M 30-34                                                            A23"
label variable a204 "F 30-34                                                            A24"
label variable a205 "P 35-39                                                            A25"
label variable a206 "M 35-39                                                            A26"
label variable a207 "F 35-39                                                            A27"
label variable a208 "P 40-44                                                            A28"
label variable a209 "M 40-44                                                            A29"
label variable a210 "F 40-44                                                            A30"
label variable a211 "P 45-49                                                            A31"
label variable a212 "M 45-49                                                            A32"
label variable a213 "F 45-49                                                            A33"
label variable a214 "P 50-54                                                            A34"
label variable a215 "M 50-54                                                            A35"
label variable a216 "F 50-54                                                            A36"
label variable a217 "P 55-59                                                            A37"
label variable a218 "M 55-59                                                            A38"
label variable a219 "F 55-59                                                            A39"
label variable a220 "P 60-64                                                            A40"
label variable a221 "M 60-64                                                            A41"
label variable a222 "F 60-64                                                            A42"
label variable a223 "P 65-69                                                            A43"
label variable a224 "M 65-69                                                            A44"
label variable a225 "F 65-69                                                            A45"
label variable a226 "P 70-74                                                            A46"
label variable a227 "M 70-74                                                            A47"
label variable a228 "F 70-74                                                            A48"
label variable a229 "P 75-79                                                            A49"
label variable a230 "M 75-79                                                            A50"
label variable a231 "F 75-79                                                            A51"
label variable a232 "P 80-84                                                            A52"
label variable a233 "M 80-84                                                            A53"
label variable a234 "F 80-84                                                            A54"
label variable a235 "P 85-89                                                            A55"
label variable a236 "M 85-89                                                            A56"
label variable a237 "F 85-89                                                            A57"
label variable a238 "P 90-94                                                            A58"
label variable a239 "M 90-94                                                            A59"
label variable a240 "F 90-94                                                            A60"
label variable a241 "P 95-99                                                            A61"
label variable a242 "M 95-99                                                            A62"
label variable a243 "F 95-99                                                            A63"
label variable a244 "P 100+                                                             A64"
label variable a245 "M 100+                                                             A65"
label variable a246 "F 100+                                                             A66"
label variable a261 "Total P aged 6+                                                     E1"
label variable a262 "Total M aged 6+                                                     E2"
label variable a263 "Total F aged 6+                                                     E3"
label variable a264 "P university                                                        E4"
label variable a265 "M                                                                   E5"
label variable a266 "F                                                                   E6"
label variable a267 "P technical/junior college                                          E7"
label variable a268 "M                                                                   E8"
label variable a269 "F                                                                   E9"
label variable a270 "P secondary technical school                                       E10"
label variable a271 "M                                                                  E11"
label variable a272 "F                                                                  E12"
label variable a273 "P senior middle school                                             E13"
label variable a274 "M                                                                  E14"
label variable a275 "F                                                                  E15"
label variable a276 "P junior middle school                                             E16"
label variable a277 "M                                                                  E17"
label variable a278 "F                                                                  E18"
label variable a279 "P primary school                                                   E19"
label variable a280 "M                                                                  E20"
label variable a281 "F                                                                  E21"
label variable a282 "P illiterate/semi-illiterate                                       E22"
label variable a283 "M                                                                  E23"
label variable a284 "F                                                                  E24"
label variable a291 "Total P 15+                                                         E1"
label variable a292 "Total M 15+                                                         E2"
label variable a293 "Total F 15+                                                         E3"
label variable a294 "P illiterate/semi-illiterate                                        E4"
label variable a295 "M                                                                   E5"
label variable a296 "F                                                                   E6"
label variable a301 "Total P 15+                                                         M1"
label variable a302 "Total M 15+                                                         M2"
label variable a303 "Total F 15+                                                         M3"
label variable a304 "P never married                                                     M4"
label variable a305 "M                                                                   M5"
label variable a306 "F                                                                   M6"
label variable a307 "P married                                                           M7"
label variable a308 "M                                                                   M8"
label variable a309 "F                                                                   M9"
label variable a310 "P widowed                                                          M10"
label variable a311 "M                                                                  M11"
label variable a312 "F                                                                  M12"
label variable a313 "P divorced                                                         M13"
label variable a314 "M                                                                  M14"
label variable a315 "F                                                                  M15"
label variable a321 "All births 1Jan89-30Jun90                                           B1"
label variable a322 "M births                                                            B2"
label variable a323 "F births                                                            B3"
label variable a324 "All births 1Jan89-30Jun89                                           B4"
label variable a325 "M births                                                            B5"
label variable a326 "F births                                                            B6"
label variable a327 "All births 1Jul89-31Dec89                                           B7"
label variable a328 "M births                                                            B8"
label variable a329 "F births                                                            B9"
label variable a330 "All births 1Jan90-30Jun90                                          B10"
label variable a331 "M births                                                           B11"
label variable a332 "F births                                                           B12"
label variable a341 "All deaths 1Jan89-30Jun90                                           D1"
label variable a342 "M deaths                                                            D2"
label variable a343 "F deaths                                                            D3"
label variable a344 "All deaths 1Jan89-30Jun89                                           D4"
label variable a345 "M deaths                                                            D5"
label variable a346 "F deaths                                                            D6"
label variable a347 "All deaths 1Jul89-31Dec89                                           D7"
label variable a348 "M deaths                                                            D8"
label variable a349 "F deaths                                                            D9"
label variable a350 "All deaths 1Jan90-30Jun90                                          D10"
label variable a351 "M deaths                                                           D11"
label variable a352 "F deaths                                                           D12"
label variable a361 "Total inmigrants                                                    R1"
label variable a362 "Within-province inmigrants: Total                                   R2"
label variable a363 "                       : from municipal cities                   R3"
label variable a364 "                       : from zhen (urban townships)             R4"
label variable a365 "                       : from xiang (rural townships)            R5"
label variable a366 "Inmigrants from other provinces: Total                              R6"
label variable a367 "                         : from municipal cities                 R7"
label variable a368 "                         : from zhen                             R8"
label variable a369 "                         : from xiang                            R9"
label variable a370 "Other inmigrants                                                   R10"
label variable a381 "Total employed P                                                    I1"
label variable a382 "Total          M                                                    I2"
label variable a383 "Total          F                                                    I3"
label variable a384 "P Agric./forestry/animal husb./fishery/water conservancy            I4"
label variable a385 "M                                                                   I5"
label variable a386 "F                                                                   I6"
label variable a387 "P Industry                                                          I7"
label variable a388 "M                                                                   I8"
label variable a389 "F                                                                   I9"
label variable a390 "P Mining, prospecting                                              I10"
label variable a391 "M                                                                  I11"
label variable a392 "F                                                                  I12"
label variable a393 "P Construction                                                     I13"
label variable a394 "M                                                                  I14"
label variable a395 "F                                                                  I15"
label variable a396 "P Transport, posts, telecommunications                             I16"
label variable a397 "M                                                                  I17"
label variable a398 "F                                                                  I18"
label variable a399 "P Commerce, supply and marketing                                   I19"
label variable a400 "M                                                                  I20"
label variable a401 "F                                                                  I21"
label variable a402 "P Real estate, utilities, residential services                     I22"
label variable a403 "M                                                                  I23"
label variable a404 "F                                                                  I24"
label variable a405 "P Medicine, health care, sports, welfare                           I25"
label variable a406 "M                                                                  I26"
label variable a407 "F                                                                  I27"
label variable a408 "P Education, culture, arts, radio, television                      I28"
label variable a409 "M                                                                  I29"
label variable a410 "F                                                                  I30"
label variable a411 "P Science, technology                                              I31"
label variable a412 "M                                                                  I32"
label variable a413 "F                                                                  I33"
label variable a414 "P Finance, insurance                                               I34"
label variable a415 "M                                                                  I35"
label variable a416 "F                                                                  I36"
label variable a417 "P Government, party, and NGOs                                      I37"
label variable a418 "M                                                                  I38"
label variable a419 "F                                                                  I39"
label variable a420 "P Other economic activities                                        I40"
label variable a421 "M                                                                  I41"
label variable a422 "F                                                                  I42"
label variable a431 "P Professional and high-level technical personnel                   O1"
label variable a432 "M                                                                   O2"
label variable a433 "F                                                                   O3"
label variable a434 "P Officials/managers in gov't, party, business, & NGOs              O4"
label variable a435 "M                                                                   O5"
label variable a436 "F                                                                   O6"
label variable a437 "P Clerical personnel                                                O7"
label variable a438 "M                                                                   O8"
label variable a439 "F                                                                   O9"
label variable a440 "P Employees in commercial sector                                   O10"
label variable a441 "M                                                                  O11"
label variable a442 "F                                                                  O12"
label variable a443 "P Employees in service sector                                      O13"
label variable a444 "M                                                                  O14"
label variable a445 "F                                                                  O15"
label variable a446 "P Workers in agric., forestry, animal husb., fisheries             O16"
label variable a447 "M                                                                  O17"
label variable a448 "F                                                                  O18"
label variable a449 "P Workers in manufacturing, construction, transport, etc.          O19"
label variable a450 "M                                                                  O20"
label variable a451 "F                                                                  O21"
label variable a452 "P Other and misc. occupations                                      O22"
label variable a453 "M                                                                  O23"
label variable a454 "F                                                                  024"
label variable a701 "P Han Chinese"
label variable a702 "M        "
label variable a703 "F        "
label variable a704 "P Mongol (Menggu) minority"
label variable a705 "M        "
label variable a706 "F        "
label variable a707 "P Hui minority"
label variable a708 "M        "
label variable a709 "F        "
label variable a710 "P Tibetan (Zang) minority"
label variable a711 "M        "
label variable a712 "F        "
label variable a713 "P Uygur (Weiwu`er) minority"
label variable a714 "M        "
label variable a715 "F        "
label variable a716 "P Miao minority"
label variable a717 "M        "
label variable a718 "F        "
label variable a719 "P Yi minority"
label variable a720 "M        "
label variable a721 "F        "
label variable a722 "P Zhuang minority"
label variable a723 "M        "
label variable a724 "F        "
label variable a725 "P Bouyei (Buyi) minority"
label variable a726 "M        "
label variable a727 "F        "
label variable a728 "P Korean (Chaoxian) minority"
label variable a729 "M        "
label variable a730 "F        "
label variable a731 "P Manchu (Man) minority"
label variable a732 "M        "
label variable a733 "F        "
label variable a734 "P Dong minority"
label variable a735 "M        "
label variable a736 "F        "
label variable a737 "P Yao minority"
label variable a738 "M        "
label variable a739 "F        "
label variable a740 "P Bai minority"
label variable a741 "M        "
label variable a742 "F        "
label variable a743 "P Tujia minority"
label variable a744 "M        "
label variable a745 "F        "
label variable a746 "P Hani minority"
label variable a747 "M        "
label variable a748 "F        "
label variable a749 "P Kazak (Hasake) minority"
label variable a750 "M        "
label variable a751 "F        "
label variable a752 "P Dai minority"
label variable a753 "M        "
label variable a754 "F        "
label variable a755 "P Li minority"
label variable a756 "M        "
label variable a757 "F        "
label variable a758 "P Lisu minority"
label variable a759 "M        "
label variable a760 "F        "
label variable a761 "P Va (Wa) minority"
label variable a762 "M        "
label variable a763 "F        "
label variable a764 "P She minority"
label variable a765 "M        "
label variable a766 "F        "
label variable a767 "P Gaoshan minority"
label variable a768 "M        "
label variable a769 "F        "
label variable a770 "P Lahu minority"
label variable a771 "M        "
label variable a772 "F        "
label variable a773 "P Shui minority"
label variable a774 "M        "
label variable a775 "F        "
label variable a776 "P Dongxiang minority"
label variable a777 "M        "
label variable a778 "F        "
label variable a779 "P Naxi minority"
label variable a780 "M        "
label variable a781 "F        "
label variable a782 "P Jingpo minority"
label variable a783 "M        "
label variable a784 "F        "
label variable a785 "P Kirgiz (Ke`erkezi) minority"
label variable a786 "M        "
label variable a787 "F        "
label variable a788 "P Tu minority"
label variable a789 "M        "
label variable a790 "F        "
label variable a791 "P Daur (Dawo`er) minority"
label variable a792 "M        "
label variable a793 "F        "
label variable a794 "P Mulam (Mulao) minority"
label variable a795 "M        "
label variable a796 "F        "
label variable a797 "P Qiang minority"
label variable a798 "M        "
label variable a799 "F        "
label variable a800 "P Blang (Bulang) minority"
label variable a801 "M        "
label variable a802 "F        "
label variable a803 "P Salar (Sala) minority"
label variable a804 "M        "
label variable a805 "F        "
label variable a806 "P Maonan minority"
label variable a807 "M        "
label variable a808 "F        "
label variable a809 "P Gelo (Gelao) minority"
label variable a810 "M        "
label variable a811 "F        "
label variable a812 "P Xibe (Xibo) minority"
label variable a813 "M        "
label variable a814 "F        "
label variable a815 "P Achang minority"
label variable a816 "M        "
label variable a817 "F        "
label variable a818 "P Pumi minority"
label variable a819 "M        "
label variable a820 "F        "
label variable a821 "P Tajik (Tajike) minority"
label variable a822 "M        "
label variable a823 "F        "
label variable a824 "P Nu minority"
label variable a825 "M        "
label variable a826 "F        "
label variable a827 "P Uzbek (Wuzibieke) minority"
label variable a828 "M        "
label variable a829 "F        "
label variable a830 "P Russian (Eluosi) minority"
label variable a831 "M        "
label variable a832 "F        "
label variable a833 "P Ewenki (Ewenke) minority"
label variable a834 "M        "
label variable a835 "F        "
label variable a836 "P De'ang minority"
label variable a837 "M        "
label variable a838 "F        "
label variable a839 "P Bonan (Bao`an) minority"
label variable a840 "M        "
label variable a841 "F        "
label variable a842 "P Yugur (Yugu) minority"
label variable a843 "M        "
label variable a844 "F        "
label variable a845 "P Jing minority"
label variable a846 "M        "
label variable a847 "F        "
label variable a848 "P Tatar (Tata`er) minority"
label variable a849 "M        "
label variable a850 "F        "
label variable a851 "P Drung (Dulong) minority"
label variable a852 "M        "
label variable a853 "F        "
label variable a854 "P Oroqen (Elunchun) minority"
label variable a855 "M        "
label variable a856 "F        "
label variable a857 "P Hezhen (Hezhe) minority"
label variable a858 "M        "
label variable a859 "F        "
label variable a860 "P Monba (Menba) minority"
label variable a861 "M        "
label variable a862 "F        "
label variable a863 "P Lhopa (Luoba) minority"
label variable a864 "M        "
label variable a865 "F        "
label variable a866 "P Jinuo minority"
label variable a867 "M        "
label variable a868 "F        "
label variable a869 "P nationality/ethnicity unknown"
label variable a870 "M                                     "
label variable a871 "F                                     "
label variable a872 "P naturalized citizens"
label variable a873 "M                       "
label variable a874 "F                       "
label variable asset_g_qz "gross asset value (QZ)"
label variable asset_n_qz "net asset value (QZ)"

sort city05 year
save ..\..\data\tabular_data_BJ\generated\pft.dta, replace

log close

erase temp_2ypf.dta
erase temp_indyb.dta
erase temp_mi3ypf.dta
erase temp_us123.dta
erase temp2_us123.dta
erase temp_qz4.dta

